package com.xhsd.zlong.generatecode.model.impl.mysql;

import java.util.List;

import com.xhsd.zlong.generatecode.utils.StringUtil;
import com.xhsd.zlong.generatecode.model.IColumn;
import com.xhsd.zlong.generatecode.model.ITable;

public class MysqlTable implements ITable{
	
	public static final String sql_show_all_tables = "SHOW TABLE STATUS";

	public static final String c_comment="Comment";
	
	public static final String c_name="Name";
	
	private String name;
	
	private String javaName;
	
	private String javaNameUpper;
	
	private String javaNameLowerAll;
	
	private String comment;
	
	private IColumn pk;
	
	private List<IColumn> columns;
	
	/**
	 * @param name 表名
	 */
	public MysqlTable(String name,String comment,List<IColumn> columns){
		
		this.setName(name);
		
		this.comment=comment;
		
		for(IColumn column:columns){
			
			if(column.isPri()){
				
				pk=column;
				
				break;
			}
		}
		
		this.columns=columns;
			
		
	}

	/**
	 * 设置表名相关的名称
	 * @param name
	 */
	private void setName(String name) {
		
		this.name=name;
		
		this.javaName=StringUtil.getJavaName(name);
		
		this.javaNameUpper=StringUtil.upperFirst(javaName);
		
		this.javaNameLowerAll = javaName.toLowerCase();
	}

	public String getName() {
		return name;
	}

	public String getJavaName() {
		return javaName;
	}

	public String getJavaNameUpper() {
		return javaNameUpper;
	}

	public String getJavaNameLowerAll() {
		return javaNameLowerAll;
	}

	public String getComment() {
		return comment;
	}

	public IColumn getPk() {
		return pk;
	}

	public List<IColumn> getColumns() {
		return columns;
	}
	
	
	
	

}
